<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge" />
    <title>Document</title>
  </head>
  <body></body>
  <script>
    /**
     * @param {number[]} nums
     * @param {number} k
     * @return {void} Do not return anything, modify nums in-place instead.
     */
    var rotate = function(nums, k) {
      if (nums.length < 2 || k === 0) {
        return;
      }
      k = k % nums.length;
      const cut = nums.splice(nums.length - k, k);
      nums.unshift(...cut);
      return nums;
    };
    console.log(rotate([1, 2, 3, 4, 5, 6, 7], 3));
  </script>
</html>
